package com.xyzq.simpson.apm.web.config;

import com.xyzq.simpson.bart.client.spring.BartPlaceholderConfigurer;
import com.xyzq.simpson.hibbert.storage.es.boot.Es7Boot;
import com.xyzq.simpson.hibbert.storage.influx.InfluxdbConnectionManager;
import com.xyzq.simpson.lisa.spring.LisaAnnotationConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;

/**
 * @Description:
 * @date 2021/4/23 9:58
 */
@Configuration
public class ApmConfig {

    @Bean
    public BartPlaceholderConfigurer bartPlaceholderConfigurer() {
        BartPlaceholderConfigurer bart = new BartPlaceholderConfigurer();
        bart.setLocation(new ClassPathResource("config/app.properties"));
        bart.setIgnoreUnresolvablePlaceholders(true);
        return bart;
    }

    @Bean
    public LisaAnnotationConfigurer lisaAnnotationConfigurer() {
        return new LisaAnnotationConfigurer();
    }

    @Bean(initMethod = "initialize", destroyMethod = "terminate")
    public Es7Boot es7Boot() {
        return new Es7Boot();
    }

    @Bean(initMethod = "initialize", destroyMethod = "terminate")
    public InfluxdbConnectionManager influxdbConnectionManager() {
        InfluxdbConnectionManager influxdbConnectionManager = new InfluxdbConnectionManager();
        influxdbConnectionManager.setNamespace("simpson-hibbert-collector.influx.namespace");
        return influxdbConnectionManager;
    }
}
